package company_of_dream;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;


/**
 *  
        
Class Employee describe object Employee
 *
 * @version      
        
1 05 Mar 2012
 * @author          
        
NataSha
 */

public class Employee {

	/** Name of Employee */
	
	String name;
	
	/** key of Employee */
	
	String password;
	
	/**
     * method readEmployeeFromFile read from file information about Employees
     * File must have .csv format with delimiter ";" 
     */
	
    public static void readEmployeeFromFile(String nameFile1) {
        try {
            final Scanner scan = new Scanner(new FileReader (nameFile1));
            ArrayList<String> word = new ArrayList<String>();
            String word1;
            String str;
            while (scan.hasNext()) {
                   str=scan.next();
                   word1 = wordInArrey(str);
                   word.add(word1);
            } 
            scan.close();
            
        } catch (FileNotFoundException e) {
            e.printStackTrace(System.err);
            }
        catch (IOException e) {
            e.printStackTrace(System.err);
        }
        }
    
    
	/**
     * method wordInArrey works with .csvformat strings and returns discrete words. 
     */ 
    
    public static String wordInArrey(String strParse) {
        
        String delemiters = " \t\n\r;";
        StringTokenizer tokenizer = new StringTokenizer(strParse, delemiters);
        String word2 = null;   
        
        while (tokenizer.hasMoreTokens()) {
            word2 = tokenizer.nextToken().replace("\"", "");
        }
        return word2;
        
    }


}
